<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('课程子详情列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>标题：</label>
                            <input type="text" name="title"/>
                            <input type="hidden"  id="vendorPackageId" name="vendorPackageId" th:value="${vendorPackageId}"/>
                            <input type="hidden"  id="parentId" name="parentId" th:value="${id}"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="addAppendixParentCourseContent()" >
                <i class="fa fa-plus"></i> 添加附件信息
            </a>

            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" >
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "system/courseContent";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            modalName: "部门",
            columns: [{
                field: 'selectItem',
                radio: true
            },
                {
                    field: 'id',
                    title: 'Id',
                },
                {
                    field: 'title',
                    title: '标题'
                },
                {
                    field: 'cover',
                    title: '封面',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return '<img  src="'+row.cover+'" height="150" width="150">';
                    }
                },
                {
                    field: 'orderNum',
                    title: '显示顺序'
                },
                {
                    field: 'created',
                    title: '创建时间'
                },
                {
                    field: 'createdName',
                    title: '创建人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs " href="javascript:void(0)" onclick="imgDetails(\'' + row.id + '\')"><i class="fa fa-edit"></i>图片详细</a> ');
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="editAppendixParentContent(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs  " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    function editAppendixParentContent(id) {
        var url = prefix + '/editAppendixParentContent/' + id;
        $.modal.open("修改附件", url,1200);
    }

    function imgDetails(id) {
        var url = prefix + '/imgDetails/' + id;
        $.modal.open("附件预览", url,1200);
    }

    function addAppendixParentCourseContent() {
        var id  = $("#parentId").val()
        var url = prefix + '/addAppendixParentCourseContent?id=' + id;
        $.modal.open("添加包子集", url,1200);
    }



</script>
</body>
</html>